#!/usr/bin/env python
#coding:utf-8

import wx
import wx.lib.agw.labelbook as LB
from wx.lib.agw.fmresources import *
import Database

class EntityDialog ( wx.Dialog ):
    
    def __init__( self, parent ):
        wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"工作实体", pos = wx.DefaultPosition, size = wx.Size( 600,420 ), style = wx.DEFAULT_DIALOG_STYLE )
        
        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
        
        bSizer1 = wx.BoxSizer( wx.VERTICAL )
        
        bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_lcList = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_REPORT )
        self.m_lcList.InsertColumn(0, u"编号")
        self.m_lcList.InsertColumn(1, u"全名")
        self.m_lcList.InsertColumn(2, u"简称")
        self.m_lcList.InsertColumn(3, u"描述")
        bSizer2.Add( self.m_lcList, 1, wx.ALL|wx.EXPAND, 5 )
        
        bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
        
        self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
        
        bSizer33 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_btnNew = wx.Button( self, wx.ID_ANY, u"新建", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer33.Add( self.m_btnNew, 0, wx.ALL, 5 )
        
        self.m_btnDelete = wx.Button( self, wx.ID_ANY, u"删除", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer33.Add( self.m_btnDelete, 0, wx.ALL, 5 )
        
        self.m_btnEdit = wx.Button( self, wx.ID_ANY, u"修改", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer33.Add( self.m_btnEdit, 0, wx.ALL, 5 )
        
        self.m_btnSubmit = wx.Button( self, wx.ID_ANY, u"提交", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer33.Add( self.m_btnSubmit, 0, wx.ALL, 5 )
        
        bSizer1.Add( bSizer33, 0, wx.EXPAND, 5 )
        
        sbSizer7 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"内容" ), wx.VERTICAL )
        
        fgSizer10 = wx.FlexGridSizer( 0, 6, 0, 0 )
        fgSizer10.SetFlexibleDirection( wx.BOTH )
        fgSizer10.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
        
        self.m_staticText50 = wx.StaticText( self, wx.ID_ANY, u"编号", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText50.Wrap( -1 )
        fgSizer10.Add( self.m_staticText50, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcNo = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_tcNo.Enable( False )
        
        fgSizer10.Add( self.m_tcNo, 0, wx.ALL, 5 )
        
        self.m_staticText51 = wx.StaticText( self, wx.ID_ANY, u"名称", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText51.Wrap( -1 )
        fgSizer10.Add( self.m_staticText51, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcFullName = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_tcFullName.Enable( False )
        
        fgSizer10.Add( self.m_tcFullName, 0, wx.ALL, 5 )
        
        self.m_staticText52 = wx.StaticText( self, wx.ID_ANY, u"代码", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText52.Wrap( -1 )
        fgSizer10.Add( self.m_staticText52, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcShortName = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_tcShortName.Enable( False )
        
        fgSizer10.Add( self.m_tcShortName, 0, wx.ALL, 5 )
        
        self.m_staticText53 = wx.StaticText( self, wx.ID_ANY, u"描述", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText53.Wrap( -1 )
        fgSizer10.Add( self.m_staticText53, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcDescribe = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_tcDescribe.Enable( False )
        
        fgSizer10.Add( self.m_tcDescribe, 0, wx.ALL, 5 )
        
        sbSizer7.Add( fgSizer10, 1, wx.EXPAND, 5 )
        
        bSizer1.Add( sbSizer7, 0, wx.EXPAND, 5 )
        
        self.m_staticline19 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer1.Add( self.m_staticline19, 0, wx.EXPAND |wx.ALL, 5 )
        
        m_sdbSizer1 = wx.StdDialogButtonSizer()
        self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK, label = u"关闭" )
        m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
        m_sdbSizer1.Realize();
        bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
        
        self.SetSizer( bSizer1 )
        self.Layout()
        
        self.Centre( wx.BOTH )
        
        # Connect Events
        self.m_lcList.Bind( wx.EVT_LIST_ITEM_SELECTED, self.OnListItemSelected )
        self.m_btnNew.Bind( wx.EVT_BUTTON, self.OnNew )
        self.m_btnDelete.Bind( wx.EVT_BUTTON, self.OnDelete )
        self.m_btnEdit.Bind( wx.EVT_BUTTON, self.OnEdit )
        self.m_btnSubmit.Bind( wx.EVT_BUTTON, self.OnSubmit )
        
        self.currentitem = None
        self.dict = {}
        self._Init()
    
    def __del__( self ):
        pass
    
    
    # Virtual event handlers, overide them in your derived class
    def OnListItemSelected( self, event ):
        self.currentitem = item = event.m_itemIndex
        self.m_tcNo.SetValue(self.m_lcList.GetItemText(item))
        self.m_tcFullName.SetValue(self.m_lcList.GetItem(item, 1).GetText())
        self.m_tcShortName.SetValue(self.m_lcList.GetItem(item, 2).GetText())
        self.m_tcDescribe.SetValue(self.m_lcList.GetItem(item, 3).GetText())
        event.Skip()
    
    def OnNew( self, event ):
        self.m_tcNo.SetValue(u"")
        self.m_tcFullName.SetValue(u"")
        self.m_tcFullName.Enable(True)
        self.m_tcShortName.SetValue(u"")
        self.m_tcShortName.Enable(True)
        self.m_tcDescribe.SetValue(u"")
        self.m_tcDescribe.Enable(True)
        event.Skip()
    
    def OnDelete( self, event ):
        if self.currentitem == None:
            wx.MessageBox(u"请选择需要删除的条目")
            return
        
        if wx.MessageBox(u"你确定需要删除吗？一旦删除您将不能恢复", u"提示", wx.YES_NO) == wx.YES:
            index = int(self.m_tcNo.GetValue())
            Database.MPartCategory.deleteBy(id = index)
            self.m_lcList.DeleteItem(self.currentitem)
            del self.dict[index]
            self.currentitem = None
            
            self.m_tcNo.SetValue(u"")
            self.m_tcFullName.SetValue(u"")
            self.m_tcFullName.Enable(False)
            self.m_tcShortName.SetValue(u"")
            self.m_tcShortName.Enable(False)
            self.m_tcDescribe.SetValue(u"")
            self.m_tcDescribe.Enable(False)
        event.Skip()
    
    def OnEdit( self, event ):
        if self.currentitem == None:
            wx.MessageBox(u"请选择需要删除的条目")
            return
    
        self.m_tcFullName.Enable(True)
        self.m_tcShortName.Enable(True)
        self.m_tcDescribe.Enable(True)
        event.Skip()
    
    def OnSubmit( self, event ):
        if self.m_tcNo.GetValue() == wx.EmptyString:
            r = Database.MEntity(name = self.m_tcFullName.GetValue(),
                                  code = self.m_tcShortName.GetValue(),
                                  describe = self.m_tcDescribe.GetValue())
            self._InsertItem(r)
        else:
            r = Database.MPartCategory.get(id = int(self.m_tcNo.GetValue()))
            r.name = self.m_tcFullName.GetValue()
            r.code = self.m_tcShortName.GetValue().encode("ascii")
            r.describe = self.m_tcDescribe.GetValue()
            
            self._UpdateItem(r)
            
        self.m_tcFullName.Enable(False)
        self.m_tcShortName.Enable(False)
        self.m_tcDescribe.Enable(False)
        event.Skip()
        
    def _Init(self):
        res = Database.MEntity.select()
        for r in res:
            self._InsertItem(r)
    
    def _InsertItem(self, r):
        item = self.m_lcList.InsertStringItem(self.m_lcList.GetItemCount(), '%d' % r.id)
        self.m_lcList.SetStringItem(item, 1, r.name)
        self.m_lcList.SetStringItem(item, 2, r.code)
        try:
            self.m_lcList.SetStringItem(item, 3, r.describe)
        except:
            pass
        self.dict[r.id] = item
        
    def _UpdateItem(self, r):
        item = self.dict[r.id]
        self.m_lcList.SetStringItem(item, 1, r.name)
        self.m_lcList.SetStringItem(item, 2, r.code)
        try:
            self.m_lcList.SetStringItem(item, 3, r.describe)
        except:
            self.m_lcList.SetStringItem(item, 3, u"")

class InfoPanel ( wx.Panel ):
    
    def __init__( self, parent, stationname = u''):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
        
        bSizer17 = wx.BoxSizer( wx.VERTICAL )
        
        bSizer18 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_bitmap2 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"images/leaf.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer18.Add( self.m_bitmap2, 0, wx.ALL, 5 )
        
        bSizer24 = wx.BoxSizer( wx.VERTICAL )
        
        self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"在这里查看工位运行信息", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText18.Wrap( -1 )
        self.m_staticText18.SetFont( wx.Font( 13, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText18.SetForegroundColour( wx.Colour( 0, 128, 0 ) )
        
        bSizer24.Add( self.m_staticText18, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_stStationName = wx.StaticText( self, wx.ID_ANY, stationname, wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stStationName.Wrap( -1 )
        self.m_stStationName.SetForegroundColour( wx.Colour( 255, 0, 0 ) )
        
        bSizer24.Add( self.m_stStationName, 0, wx.ALL, 5 )
        
        bSizer18.Add( bSizer24, 0, wx.ALIGN_CENTER_VERTICAL, 5 )
        
        bSizer17.Add( bSizer18, 0, wx.EXPAND, 5 )
        
        self.m_staticline10 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer17.Add( self.m_staticline10, 0, wx.EXPAND |wx.ALL, 5 )
        
        sbSizer1 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"当前生产任务" ), wx.VERTICAL )
        
        fgSizer6 = wx.FlexGridSizer( 0, 4, 0, 0 )
        fgSizer6.SetFlexibleDirection( wx.BOTH )
        fgSizer6.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
        
        self.m_staticText19 = wx.StaticText( self, wx.ID_ANY, u"总成型号：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText19.Wrap( -1 )
        fgSizer6.Add( self.m_staticText19, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcType = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 150,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer6.Add( self.m_tcType, 0, wx.ALL, 5 )
        
        self.m_staticText20 = wx.StaticText( self, wx.ID_ANY, u"总成方向：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText20.Wrap( -1 )
        fgSizer6.Add( self.m_staticText20, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcHand = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 150,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer6.Add( self.m_tcHand, 0, wx.ALL, 5 )
        
        self.m_staticText41 = wx.StaticText( self, wx.ID_ANY, u"应装配数量：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText41.Wrap( -1 )
        fgSizer6.Add( self.m_staticText41, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcShouldCount = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer6.Add( self.m_tcShouldCount, 0, wx.ALL|wx.EXPAND, 5 )
        
        self.m_staticText42 = wx.StaticText( self, wx.ID_ANY, u"已装配数量：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText42.Wrap( -1 )
        fgSizer6.Add( self.m_staticText42, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcAlreadyCount = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer6.Add( self.m_tcAlreadyCount, 0, wx.ALL|wx.EXPAND, 5 )
        
        sbSizer1.Add( fgSizer6, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
        
        bSizer17.Add( sbSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, 5 )
        
        sbSizer2 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"运行记录" ), wx.VERTICAL )
        
        fgSizer9 = wx.FlexGridSizer( 0, 4, 0, 0 )
        fgSizer9.SetFlexibleDirection( wx.BOTH )
        fgSizer9.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
        
        self.m_staticText45 = wx.StaticText( self, wx.ID_ANY, u"工作状态：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText45.Wrap( -1 )
        fgSizer9.Add( self.m_staticText45, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcWorkState = wx.TextCtrl( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer9.Add( self.m_tcWorkState, 0, wx.ALL, 5 )
        
        self.m_staticText46 = wx.StaticText( self, wx.ID_ANY, u"最后一次加工时间：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText46.Wrap( -1 )
        fgSizer9.Add( self.m_staticText46, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcLastTime = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 150,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer9.Add( self.m_tcLastTime, 0, wx.ALL, 5 )
        
        self.m_staticText48 = wx.StaticText( self, wx.ID_ANY, u"工作结果：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText48.Wrap( -1 )
        fgSizer9.Add( self.m_staticText48, 0, wx.ALL, 5 )
        
        self.m_tcLastResult = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer9.Add( self.m_tcLastResult, 0, wx.ALL, 5 )
        
        self.m_staticText21 = wx.StaticText( self, wx.ID_ANY, u"合格数量：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText21.Wrap( -1 )
        fgSizer9.Add( self.m_staticText21, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcOKCount = wx.TextCtrl( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcOKCount.SetBackgroundColour( wx.Colour( 128, 255, 0 ) )
        
        fgSizer9.Add( self.m_tcOKCount, 0, wx.ALL|wx.EXPAND, 5 )
        
        self.m_staticText22 = wx.StaticText( self, wx.ID_ANY, u"不合格数量：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText22.Wrap( -1 )
        fgSizer9.Add( self.m_staticText22, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcNOKCount = wx.TextCtrl( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcNOKCount.SetBackgroundColour( wx.Colour( 255, 128, 128 ) )
        
        fgSizer9.Add( self.m_tcNOKCount, 0, wx.ALL|wx.EXPAND, 5 )
        
        self.m_staticText25 = wx.StaticText( self, wx.ID_ANY, u"合格率：", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText25.Wrap( -1 )
        fgSizer9.Add( self.m_staticText25, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcPerOfPass = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_RIGHT )
        fgSizer9.Add( self.m_tcPerOfPass, 0, wx.ALL|wx.EXPAND, 5 )
        
        sbSizer2.Add( fgSizer9, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
        
        self.m_tcWorkInfo = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_READONLY|wx.TE_CENTER )
        sbSizer2.Add( self.m_tcWorkInfo, 0, wx.ALL|wx.EXPAND, 5 )
        
        bSizer17.Add( sbSizer2, 0, wx.EXPAND, 5 )
        
        self.SetSizer( bSizer17 )
        self.Layout()
        bSizer17.Fit( self )
        
    def SetController(self, con):
        self.controller = con
    
    def Update(self):
        info = self.controller.GetAssemblyInfo()
        self.m_tcType.SetValue(info['type'])
        self.m_tcHand.SetValue(info['hand'])
        self.m_tcShouldCount.SetValue(info['total'])
        self.m_tcAlreadyCount.SetValue(info['count'])
        
        info = self.controller.GetRunInfo()
        self.m_tcWorkState.SetValue(info['state'])
        self.m_tcLastTime.SetValue(info['lasttime'])
        self.m_tcLastResult.SetValue(info['lastpart'])
        self.m_tcOKCount.SetValue(info['okcnt'])
        self.m_tcNOKCount.SetValue(info['nokcnt'])
        self.m_tcPerOfPass.SetValue(info['perofpass'])
        self.m_tcWorkInfo.SetValue(info['extinfo'])
        
class TaskPanel ( wx.Panel ):
    
    def __init__( self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
        
        bSizer26 = wx.BoxSizer( wx.VERTICAL )
        
        bSizer27 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_bitmap5 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"images/wheel.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer27.Add( self.m_bitmap5, 0, wx.ALL, 5 )
        
        self.m_staticText18 = wx.StaticText( self, wx.ID_ANY, u"在这里查看工位任务列表", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText18.Wrap( -1 )
        self.m_staticText18.SetFont( wx.Font( 13, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText18.SetForegroundColour( wx.Colour( 0, 128, 0 ) )
        
        bSizer27.Add( self.m_staticText18, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        bSizer26.Add( bSizer27, 0, wx.EXPAND, 5 )
        
        self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer26.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 )
        
        self.m_listCtrl3 = wx.ListCtrl( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_HRULES|wx.LC_REPORT )
        bSizer26.Add( self.m_listCtrl3, 1, wx.ALL|wx.EXPAND, 5 )
        
        self.SetSizer( bSizer26 )
        self.Layout()
        
        self.Init()
        
    def Init(self):
        self.m_listCtrl3.InsertColumn(0, u'编号', width = 60)
        self.m_listCtrl3.InsertColumn(1, u'总成型号', width = 100)
        self.m_listCtrl3.InsertColumn(2, u'总成方向', width = 80)
        self.m_listCtrl3.InsertColumn(3, u'计划数量', width = 100)
        self.m_listCtrl3.InsertColumn(4, u'已装配数', width = 100)
        
    def SetController(self, con):
        self.controller = con
        
    def Update(self):
        info = self.controller.GetTaskInfo()
        self.m_listCtrl3.DeleteAllItems()
        for i, v in enumerate(info):
            self.m_listCtrl3.InsertStringItem(i, '%d' % (i+1))
            self.m_listCtrl3.SetStringItem(i, 1, v[0])
            self.m_listCtrl3.SetStringItem(i, 2, v[1])
            self.m_listCtrl3.SetStringItem(i, 3, '%d' % v[2])
            self.m_listCtrl3.SetStringItem(i, 4, '%d' % v[3])
        
class BookWindow(LB.FlatImageBook):
    def __init__(self, parent):
        LB.FlatImageBook.__init__(self, parent, agwStyle = LB.INB_SHOW_ONLY_TEXT | LB.INB_SHOW_ONLY_IMAGES | LB.INB_LEFT | LB.INB_BORDER)
        self.controller = None
        
        isz = (32,32)
        il = wx.ImageList(isz[0], isz[1])
        il.Add(wx.Bitmap('images/info32_32.png'))
        il.Add(wx.Bitmap('images/task32_32.png'))
        
        self.AssignImageList(il)
        
        self.info = InfoPanel(self)
        self.task = TaskPanel(self)
        self.AddPage(self.info, u'信息', True, 0)
        self.AddPage(self.task, u'任务', False, 1)
        
    def SetController(self, con):
        self.controller = con
        self.info.SetController(con)
        self.task.SetController(con)
        
    def Update(self):
        self.info.Update()
        self.task.Update()
        
    def UpdateTaskInfo(self):
        self.task.Update()
        
    def UpdateInfo(self):
        self.info.Update()